home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
tex
/
ngclon11.zip
/
NG_CLONE.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1990-02-21
|
50KB
|
1,510 lines
{$M 4096,0,0} {Reduce stack and heap}
{$R-,I-} {Cut off range and I/O checking}
program ng_clone;
{After all, that's what it is; Thank you, Mr. Norton, you are among my heroes!}
uses crt,tesstp5;
{TESS version MUST match compiler version}
type
gentry=record {General entry type}
filptr:longint;
name:string[40];
end;
textel= record {Text-mode screen element}
cha:byte;
att:byte;
end;
fiftylinebuf= array[1..50,1..80] of textel; {Video buffer types}
twelwebuf= array[1..12,1..80] of textel;
savedline= array[1..80] of textel;
var
screen:fiftylinebuf absolute $B800:$0000; {Text-mode screen, }
{should be B000:0000h }
{on monochrome }
csr:word absolute $0040:$0060; {Low-memory cursor info}
screenmode:word absolute $0040:$0049; {Low-memory screen info}
numrows:word absolute $0040:$0084; {Low-memory screen info}
savedscreen:fiftylinebuf; {Buffer save current screen on entry}
smallscreen:twelwebuf; {Buffer holds screen template}
menuline:array[0..1] of savedline; {Buffer screen template}
largescreen:array[0..1] of savedline; {Buffer screen template}
scrollbuffer:array[0..511] of string[84]; {Buffer guide text entry}
infobuffer:array[0..511] of longint; {Buffer guide file info}
seealso:array[0..19] of gentry; {Buffer guide file info}
menu:array[0..2] of string[9]; {Buffer to hold static part of guide menu structure}
mennu:array[0..3,0..8] of gentry; {Buffer to hold variable part of guide menu structure}
backstack:array[0..3] of byte; {TESS background stack}
itemlist:array[0..3] of byte; {Menu structure info}
menuplaces,menulengths:array[0..6] of byte; {Stacks for nested menu structures}
errorinfo:array[3..6] of string[14]; {Buffer for error messages}
f:file; {The guide file}
propath,homedir,streng:string; {String variables, mostly for path and file use}
tsrstring:string[8]; {TESS ID string}
parent:array[0..3] of longint; {Stack for nested menu structures}
poffset:array[0..3] of word; {Stack for nested menu structures}
pcurpos:array[0..3] of byte; {Stack for nested menu structures}
defptr,stackptr:pointer; {TESS pointers}
previous,next:longint; {Previous and next entry}
idnum,i,j,offset,ch,id,bufferlength,savedcsr:word; {Word variables}
erro,wix,wiy,curpos,entrytype,seealsonum,sapos,level,scrtypeflag,startline,
txtattri,
Normal_Text,
UnderScore,
Bold_Face,
Select_Cursor,
Menu_Text,
mlevel,xchoice,ychoice,menux,menuy,menuantal,menunr:byte; {Byte variables}
procedure hidecrsr; {Make cursor invisible on CGA,EGA or VGA}
begin
inline($B4/$01/$B5/$20/$CD/$10);
end;
function restorecrsr(crsr:word):boolean;
{Restore saved cursor on CGA,EGA or VGA}
inline($B4/$01/$59/$CD/$10);
function key:word; {Keyboard interrupt}
inline($CD/$16);
procedure keyread(var karakter:word);
{Readkey replacement}
var tch:char;
begin
karakter:=key;
if (lo(karakter)=0) then {If extended key, add 256 to value of key code}
begin
tch:=char(hi(karakter));
karakter:=ord(tch)+256;
end
else {Else return key code as is}
begin
tch:=char(lo(karakter));
karakter:=ord(tch);
end;
end;
procedure writestring(cux,cuy,startattr,change,extra:byte;cus:string); {Direct screen write}
var jcount,ycount,tmpchr:byte;
jch:char;
begin
jcount:=0;ycount:=0;txtattri:=startattr;
repeat
inc(jcount);
jch:=cus[jcount];
if jch<>'^' then {If not NG control code, write character as is}
begin
if jch=#255 then {Expand spaces}
begin
inc(jcount);
jch:=cus[jcount];
for ycount:=ycount to ycount+ord(jch) do
begin
screen[cuy,cux+ycount].cha:=32;
screen[cuy,cux+ycount].att:=txtattri;
end;
end
else
begin
screen[cuy,cux+ycount].cha:=ord(jch);
screen[cuy,cux+ycount].att:=txtattri;
inc(ycount);
end;
end
else {Control code found!}
begin
inc(jcount);
jch:=cus[jcount];
if ((jch='A') or (jch='a')) then {Color attribute command}
begin
inc(jcount);
jch:=cus[jcount];
if change=1 then
begin
if ((ord(jch)>47) and (ord(jch)<58)) then txtattri:=ord(jch)-48 else
if ((ord(jch)>64) and (ord(jch)<71)) then txtattri:=ord(jch)-55;
txtattri:=16*txtattri;
end;
inc(jcount);
jch:=cus[jcount];
if change=1 then
begin
if ((ord(jch)>47) and (ord(jch)<58)) then txtattri:=txtattri+ord(jch)-48 else
if ((ord(jch)>64) and (ord(jch)<71)) then txtattri:=txtattri+ord(jch)-55;
end;
end
else if ((jch='C') or (jch='c')) then {Difficult character}
begin
inc(jcount);
jch:=cus[jcount];
if ((ord(jch)>47) and (ord(jch)<58)) then tmpchr:=ord(jch)-48 else
if ((ord(jch)>64) and (ord(jch)<71)) then tmpchr:=ord(jch)-55;
tmpchr:=16*tmpchr;
inc(jcount);
jch:=cus[jcount];
if ((ord(jch)>47) and (ord(jch)<58)) then tmpchr:=tmpchr+ord(jch)-48 else
if ((ord(jch)>64) and (ord(jch)<71)) then tmpchr:=tmpchr+ord(jch)-55;
screen[cuy,cux+ycount].cha:=tmpchr;
screen[cuy,cux+ycount].att:=txtattri;
inc(ycount);
end
else if ((jch='b') or (jch='B')) then {Boldface (?)}
begin
if change=1 then
begin
if txtattri=Normal_Text then txtattri:=Bold_Face else txtattri:=Normal_Text;
end;
end
else if ((jch='u') or (jch='U')) then {Underline (?)}
begin
if change=1 then
begin
if txtattri=Normal_Text then txtattri:=UnderScore else txtattri:=Normal_Text;
end;
end
else if jch='^' then {Write control character itself}
begin
screen[cuy,cux+ycount].cha:=ord(jch);
screen[cuy,cux+ycount].att:=txtattri;
inc(ycount);
end;
end;
until jcount>=length(cus);
if extra>0 then {If desired, fill with blanks}
begin
while ycount<extra do
begin
screen[cuy,cux+ycount].cha:=32;
screen[cuy,cux+ycount].att:=txtattri;
inc(ycount);
end;
end;
end;
procedure threenitvars; {Initialize variables}
begin
menunr:=0;
level:=0;
curpos:=0;
offset:=0;
menux:=3;
menuy:=0;
mlevel:=0;
xchoice:=0;
ychoice:=0;
sapos:=0;